package com.sgb.kjwl.view.ui.adapter.home;

import com.blankj.utilcode.util.ColorUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemGoodsIndexBinding;
import com.sgb.kjwl.model.entity.user.GoodsIndexEntity;
import com.sgb.kjwl.view.ui.adapter.self.order.DataBindingViewHolder;

import java.util.List;

/**
 * @author PC
 */
public class GoodsIndexAdapter extends BaseQuickAdapter<GoodsIndexEntity, DataBindingViewHolder> {

    private ItemGoodsIndexBinding binding;

    public GoodsIndexAdapter(List<GoodsIndexEntity> data) {
        super(R.layout.item_goods_index, data);
    }

    @Override
    protected void convert(DataBindingViewHolder helper, GoodsIndexEntity item) {
        binding = (ItemGoodsIndexBinding) helper.getBinding();
        binding.tvTitle.setText(item.getTitle());
        if (item.isSelect()) {
            binding.tvTitle.setTextColor(ColorUtils.getColor(R.color.white));
            binding.tvTitle.setBackgroundResource(R.drawable.good_index_red_5);
        } else {
            binding.tvTitle.setTextColor(ColorUtils.getColor(R.color.color_333333));
            binding.tvTitle.setBackgroundResource(R.drawable.good_index_gray_5);
        }
    }

}
